package cn.ibizlab.odoo.core.odoo_mrp.service.impl;

import java.io.Serializable;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.HashMap;
import java.math.BigInteger;
import java.util.Collection;

import lombok.extern.slf4j.Slf4j;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cglib.beans.BeanCopier;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import cn.ibizlab.odoo.core.client.model.Imrp_workorder;
import cn.ibizlab.odoo.core.odoo_mrp.domain.Mrp_workorder;
import cn.ibizlab.odoo.core.odoo_mrp.filter.Mrp_workorderSearchContext;
import cn.ibizlab.odoo.core.odoo_mrp.service.IMrp_workorderService;
import cn.ibizlab.odoo.util.SearchResult;
import cn.ibizlab.odoo.util.log.IBIZLog;

/**
 * 实体[工单] 服务对象接口实现
 */
@Slf4j
@IBIZLog
@Service
public class Mrp_workorderServiceImpl implements IMrp_workorderService {

    @Autowired
    private cn.ibizlab.odoo.core.client.service.Imrp_workorderClientService mrp_workorderClientService;

    @Override
    public void createBatch(List<Mrp_workorder> mrp_workorders, int batchSize) {

                        //mrp_workorderClientService.createBatch(mrp_workorders,batchSize) ;

    }

    @Override
    public boolean update(Mrp_workorder mrp_workorder) {
        boolean bOk = false ;
        Imrp_workorder clientModel = this.convert2Model(mrp_workorder,null);
        mrp_workorderClientService.update(clientModel) ;
        this.convert2Domain(clientModel,mrp_workorder) ;
        bOk = true;
        return bOk ;
    }

    @Override
    public void updateBatch(List<Mrp_workorder> mrp_workorders, int batchSize) {

        //mrp_workorderClientService.updateBatch(mrp_workorders,batchSize) ;

    }

    @Override
    public boolean remove(Integer id) {
        boolean bOk = false ;
        Imrp_workorder clientModel = mrp_workorderClientService.createModel();
        clientModel.setId(id);
        mrp_workorderClientService.remove(clientModel) ;
        bOk = true ;
        return bOk ;
    }

    @Override
    public Mrp_workorder get(Integer id) {
        Imrp_workorder clientModel = mrp_workorderClientService.createModel();
        clientModel.setId(id);
        mrp_workorderClientService.get(clientModel) ;
        return this.convert2Domain(clientModel,null);
    }

    @Override
    public Mrp_workorder get(Mrp_workorder mrp_workorder) {
        Mrp_workorder retmrp_workorder = this.get(mrp_workorder.getId()) ;
    	BeanCopier copier=BeanCopier.create(retmrp_workorder.getClass(), mrp_workorder.getClass(), false);
        copier.copy(retmrp_workorder, mrp_workorder, null);
        return mrp_workorder ;
    }

    @Override
    public boolean create(Mrp_workorder mrp_workorder) {
        boolean bOk = false ;
        Imrp_workorder clientModel = this.convert2Model(mrp_workorder,null);
        mrp_workorderClientService.create(clientModel) ;
        this.convert2Domain(clientModel,mrp_workorder);
        bOk = true ;

        return bOk ;
    }

    @Override
    public void removeBatch(Collection<? extends Serializable> idList, int batchSize) {

        //mrp_workorderClientService.removeBatch(mrp_workorders) ;

    }

    /**
     * 查询集合 默认查询
     */
    @Override
    public Page<Mrp_workorder> searchDefault(Mrp_workorderSearchContext context) {
        List<Mrp_workorder> list = new ArrayList<Mrp_workorder>();
        Page<cn.ibizlab.odoo.core.client.model.Imrp_workorder> clientModelList = mrp_workorderClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Imrp_workorder clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Mrp_workorder>(list, context.getPageable(), clientModelList.getTotalElements());
    }


    /**
     * 根据Production Order查询
     */
    @Override
    public Page<Mrp_workorder> selectByOdoo_production(Integer id){
        Mrp_workorderSearchContext context = new Mrp_workorderSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Mrp_workorder> list = new ArrayList<Mrp_workorder>();
        Page<cn.ibizlab.odoo.core.client.model.Imrp_workorder> clientModelList = mrp_workorderClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Imrp_workorder clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Mrp_workorder>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据工作中心使用情况查询
     */
    @Override
    public Page<Mrp_workorder> selectByOdoo_operation(Integer id){
        Mrp_workorderSearchContext context = new Mrp_workorderSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Mrp_workorder> list = new ArrayList<Mrp_workorder>();
        Page<cn.ibizlab.odoo.core.client.model.Imrp_workorder> clientModelList = mrp_workorderClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Imrp_workorder clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Mrp_workorder>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据工作中心查询
     */
    @Override
    public Page<Mrp_workorder> selectByOdoo_workcenter(Integer id){
        Mrp_workorderSearchContext context = new Mrp_workorderSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Mrp_workorder> list = new ArrayList<Mrp_workorder>();
        Page<cn.ibizlab.odoo.core.client.model.Imrp_workorder> clientModelList = mrp_workorderClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Imrp_workorder clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Mrp_workorder>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据工单查询
     */
    @Override
    public Page<Mrp_workorder> selectByOdoo_next_work_order(Integer id){
        Mrp_workorderSearchContext context = new Mrp_workorderSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Mrp_workorder> list = new ArrayList<Mrp_workorder>();
        Page<cn.ibizlab.odoo.core.client.model.Imrp_workorder> clientModelList = mrp_workorderClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Imrp_workorder clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Mrp_workorder>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据产品查询
     */
    @Override
    public Page<Mrp_workorder> selectByOdoo_product(Integer id){
        Mrp_workorderSearchContext context = new Mrp_workorderSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Mrp_workorder> list = new ArrayList<Mrp_workorder>();
        Page<cn.ibizlab.odoo.core.client.model.Imrp_workorder> clientModelList = mrp_workorderClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Imrp_workorder clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Mrp_workorder>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据用户查询
     */
    @Override
    public Page<Mrp_workorder> selectByOdoo_create(Integer id){
        Mrp_workorderSearchContext context = new Mrp_workorderSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Mrp_workorder> list = new ArrayList<Mrp_workorder>();
        Page<cn.ibizlab.odoo.core.client.model.Imrp_workorder> clientModelList = mrp_workorderClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Imrp_workorder clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Mrp_workorder>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据用户查询
     */
    @Override
    public Page<Mrp_workorder> selectByOdoo_write(Integer id){
        Mrp_workorderSearchContext context = new Mrp_workorderSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Mrp_workorder> list = new ArrayList<Mrp_workorder>();
        Page<cn.ibizlab.odoo.core.client.model.Imrp_workorder> clientModelList = mrp_workorderClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Imrp_workorder clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Mrp_workorder>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据批次/序列号查询
     */
    @Override
    public Page<Mrp_workorder> selectByOdoo_final_lot(Integer id){
        Mrp_workorderSearchContext context = new Mrp_workorderSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Mrp_workorder> list = new ArrayList<Mrp_workorder>();
        Page<cn.ibizlab.odoo.core.client.model.Imrp_workorder> clientModelList = mrp_workorderClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Imrp_workorder clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Mrp_workorder>(list, context.getPageable(), clientModelList.getTotalElements());

    }



    public Imrp_workorder convert2Model(Mrp_workorder domain , Imrp_workorder model) {
        if(domain == null)
            return model ;
        if(model==null){
            model = mrp_workorderClientService.createModel() ;
        }

         if(domain.getMessage_is_followerDirtyFlag())
            model.setMessage_is_follower(domain.getMessage_is_follower());
         if(domain.getMessage_unreadDirtyFlag())
            model.setMessage_unread(domain.getMessage_unread());
         if(domain.getMessage_has_errorDirtyFlag())
            model.setMessage_has_error(domain.getMessage_has_error());
         if(domain.getTime_idsDirtyFlag())
            model.setTime_ids(domain.getTime_ids());
         if(domain.getMessage_idsDirtyFlag())
            model.setMessage_ids(domain.getMessage_ids());
         if(domain.getWorking_user_idsDirtyFlag())
            model.setWorking_user_ids(domain.getWorking_user_ids());
         if(domain.getDisplay_nameDirtyFlag())
            model.setDisplay_name(domain.getDisplay_name());
         if(domain.getQty_producedDirtyFlag())
            model.setQty_produced(domain.getQty_produced());
         if(domain.getDurationDirtyFlag())
            model.setDuration(domain.getDuration());
         if(domain.getMessage_partner_idsDirtyFlag())
            model.setMessage_partner_ids(domain.getMessage_partner_ids());
         if(domain.getStateDirtyFlag())
            model.setState(domain.getState());
         if(domain.getScrap_countDirtyFlag())
            model.setScrap_count(domain.getScrap_count());
         if(domain.getDate_planned_startDirtyFlag())
            model.setDate_planned_start(domain.getDate_planned_start());
         if(domain.getMessage_needactionDirtyFlag())
            model.setMessage_needaction(domain.getMessage_needaction());
         if(domain.getIs_user_workingDirtyFlag())
            model.setIs_user_working(domain.getIs_user_working());
         if(domain.getMove_raw_idsDirtyFlag())
            model.setMove_raw_ids(domain.getMove_raw_ids());
         if(domain.getLast_working_user_idDirtyFlag())
            model.setLast_working_user_id(domain.getLast_working_user_id());
         if(domain.getMessage_needaction_counterDirtyFlag())
            model.setMessage_needaction_counter(domain.getMessage_needaction_counter());
         if(domain.getMove_line_idsDirtyFlag())
            model.setMove_line_ids(domain.getMove_line_ids());
         if(domain.getNameDirtyFlag())
            model.setName(domain.getName());
         if(domain.getIs_first_woDirtyFlag())
            model.setIs_first_wo(domain.getIs_first_wo());
         if(domain.getIs_producedDirtyFlag())
            model.setIs_produced(domain.getIs_produced());
         if(domain.getDate_startDirtyFlag())
            model.setDate_start(domain.getDate_start());
         if(domain.getWebsite_message_idsDirtyFlag())
            model.setWebsite_message_ids(domain.getWebsite_message_ids());
         if(domain.get__last_updateDirtyFlag())
            model.set__last_update(domain.get__last_update());
         if(domain.getMessage_follower_idsDirtyFlag())
            model.setMessage_follower_ids(domain.getMessage_follower_ids());
         if(domain.getColorDirtyFlag())
            model.setColor(domain.getColor());
         if(domain.getMessage_attachment_countDirtyFlag())
            model.setMessage_attachment_count(domain.getMessage_attachment_count());
         if(domain.getWrite_dateDirtyFlag())
            model.setWrite_date(domain.getWrite_date());
         if(domain.getMessage_channel_idsDirtyFlag())
            model.setMessage_channel_ids(domain.getMessage_channel_ids());
         if(domain.getDuration_unitDirtyFlag())
            model.setDuration_unit(domain.getDuration_unit());
         if(domain.getMessage_main_attachment_idDirtyFlag())
            model.setMessage_main_attachment_id(domain.getMessage_main_attachment_id());
         if(domain.getCapacityDirtyFlag())
            model.setCapacity(domain.getCapacity());
         if(domain.getActive_move_line_idsDirtyFlag())
            model.setActive_move_line_ids(domain.getActive_move_line_ids());
         if(domain.getDate_planned_finishedDirtyFlag())
            model.setDate_planned_finished(domain.getDate_planned_finished());
         if(domain.getDate_finishedDirtyFlag())
            model.setDate_finished(domain.getDate_finished());
         if(domain.getQty_remainingDirtyFlag())
            model.setQty_remaining(domain.getQty_remaining());
         if(domain.getScrap_idsDirtyFlag())
            model.setScrap_ids(domain.getScrap_ids());
         if(domain.getDuration_percentDirtyFlag())
            model.setDuration_percent(domain.getDuration_percent());
         if(domain.getIdDirtyFlag())
            model.setId(domain.getId());
         if(domain.getCreate_dateDirtyFlag())
            model.setCreate_date(domain.getCreate_date());
         if(domain.getDuration_expectedDirtyFlag())
            model.setDuration_expected(domain.getDuration_expected());
         if(domain.getMessage_has_error_counterDirtyFlag())
            model.setMessage_has_error_counter(domain.getMessage_has_error_counter());
         if(domain.getMessage_unread_counterDirtyFlag())
            model.setMessage_unread_counter(domain.getMessage_unread_counter());
         if(domain.getQty_producingDirtyFlag())
            model.setQty_producing(domain.getQty_producing());
         if(domain.getProduction_dateDirtyFlag())
            model.setProduction_date(domain.getProduction_date());
         if(domain.getWorksheetDirtyFlag())
            model.setWorksheet(domain.getWorksheet());
         if(domain.getWorkcenter_id_textDirtyFlag())
            model.setWorkcenter_id_text(domain.getWorkcenter_id_text());
         if(domain.getFinal_lot_id_textDirtyFlag())
            model.setFinal_lot_id_text(domain.getFinal_lot_id_text());
         if(domain.getWorking_stateDirtyFlag())
            model.setWorking_state(domain.getWorking_state());
         if(domain.getQty_productionDirtyFlag())
            model.setQty_production(domain.getQty_production());
         if(domain.getProduct_uom_idDirtyFlag())
            model.setProduct_uom_id(domain.getProduct_uom_id());
         if(domain.getCreate_uid_textDirtyFlag())
            model.setCreate_uid_text(domain.getCreate_uid_text());
         if(domain.getProduction_availabilityDirtyFlag())
            model.setProduction_availability(domain.getProduction_availability());
         if(domain.getProduction_stateDirtyFlag())
            model.setProduction_state(domain.getProduction_state());
         if(domain.getNext_work_order_id_textDirtyFlag())
            model.setNext_work_order_id_text(domain.getNext_work_order_id_text());
         if(domain.getOperation_id_textDirtyFlag())
            model.setOperation_id_text(domain.getOperation_id_text());
         if(domain.getWrite_uid_textDirtyFlag())
            model.setWrite_uid_text(domain.getWrite_uid_text());
         if(domain.getProduction_id_textDirtyFlag())
            model.setProduction_id_text(domain.getProduction_id_text());
         if(domain.getProduct_id_textDirtyFlag())
            model.setProduct_id_text(domain.getProduct_id_text());
         if(domain.getProduct_trackingDirtyFlag())
            model.setProduct_tracking(domain.getProduct_tracking());
         if(domain.getFinal_lot_idDirtyFlag())
            model.setFinal_lot_id(domain.getFinal_lot_id());
         if(domain.getWorkcenter_idDirtyFlag())
            model.setWorkcenter_id(domain.getWorkcenter_id());
         if(domain.getProduction_idDirtyFlag())
            model.setProduction_id(domain.getProduction_id());
         if(domain.getWrite_uidDirtyFlag())
            model.setWrite_uid(domain.getWrite_uid());
         if(domain.getOperation_idDirtyFlag())
            model.setOperation_id(domain.getOperation_id());
         if(domain.getNext_work_order_idDirtyFlag())
            model.setNext_work_order_id(domain.getNext_work_order_id());
         if(domain.getProduct_idDirtyFlag())
            model.setProduct_id(domain.getProduct_id());
         if(domain.getCreate_uidDirtyFlag())
            model.setCreate_uid(domain.getCreate_uid());
        return model ;
    }

    public Mrp_workorder convert2Domain( Imrp_workorder model ,Mrp_workorder domain) {
        if(model == null)
            return domain ;
        if(domain == null){
            domain = new Mrp_workorder();
        }

        if(model.getMessage_is_followerDirtyFlag())
            domain.setMessage_is_follower(model.getMessage_is_follower());
        if(model.getMessage_unreadDirtyFlag())
            domain.setMessage_unread(model.getMessage_unread());
        if(model.getMessage_has_errorDirtyFlag())
            domain.setMessage_has_error(model.getMessage_has_error());
        if(model.getTime_idsDirtyFlag())
            domain.setTime_ids(model.getTime_ids());
        if(model.getMessage_idsDirtyFlag())
            domain.setMessage_ids(model.getMessage_ids());
        if(model.getWorking_user_idsDirtyFlag())
            domain.setWorking_user_ids(model.getWorking_user_ids());
        if(model.getDisplay_nameDirtyFlag())
            domain.setDisplay_name(model.getDisplay_name());
        if(model.getQty_producedDirtyFlag())
            domain.setQty_produced(model.getQty_produced());
        if(model.getDurationDirtyFlag())
            domain.setDuration(model.getDuration());
        if(model.getMessage_partner_idsDirtyFlag())
            domain.setMessage_partner_ids(model.getMessage_partner_ids());
        if(model.getStateDirtyFlag())
            domain.setState(model.getState());
        if(model.getScrap_countDirtyFlag())
            domain.setScrap_count(model.getScrap_count());
        if(model.getDate_planned_startDirtyFlag())
            domain.setDate_planned_start(model.getDate_planned_start());
        if(model.getMessage_needactionDirtyFlag())
            domain.setMessage_needaction(model.getMessage_needaction());
        if(model.getIs_user_workingDirtyFlag())
            domain.setIs_user_working(model.getIs_user_working());
        if(model.getMove_raw_idsDirtyFlag())
            domain.setMove_raw_ids(model.getMove_raw_ids());
        if(model.getLast_working_user_idDirtyFlag())
            domain.setLast_working_user_id(model.getLast_working_user_id());
        if(model.getMessage_needaction_counterDirtyFlag())
            domain.setMessage_needaction_counter(model.getMessage_needaction_counter());
        if(model.getMove_line_idsDirtyFlag())
            domain.setMove_line_ids(model.getMove_line_ids());
        if(model.getNameDirtyFlag())
            domain.setName(model.getName());
        if(model.getIs_first_woDirtyFlag())
            domain.setIs_first_wo(model.getIs_first_wo());
        if(model.getIs_producedDirtyFlag())
            domain.setIs_produced(model.getIs_produced());
        if(model.getDate_startDirtyFlag())
            domain.setDate_start(model.getDate_start());
        if(model.getWebsite_message_idsDirtyFlag())
            domain.setWebsite_message_ids(model.getWebsite_message_ids());
        if(model.get__last_updateDirtyFlag())
            domain.set__last_update(model.get__last_update());
        if(model.getMessage_follower_idsDirtyFlag())
            domain.setMessage_follower_ids(model.getMessage_follower_ids());
        if(model.getColorDirtyFlag())
            domain.setColor(model.getColor());
        if(model.getMessage_attachment_countDirtyFlag())
            domain.setMessage_attachment_count(model.getMessage_attachment_count());
        if(model.getWrite_dateDirtyFlag())
            domain.setWrite_date(model.getWrite_date());
        if(model.getMessage_channel_idsDirtyFlag())
            domain.setMessage_channel_ids(model.getMessage_channel_ids());
        if(model.getDuration_unitDirtyFlag())
            domain.setDuration_unit(model.getDuration_unit());
        if(model.getMessage_main_attachment_idDirtyFlag())
            domain.setMessage_main_attachment_id(model.getMessage_main_attachment_id());
        if(model.getCapacityDirtyFlag())
            domain.setCapacity(model.getCapacity());
        if(model.getActive_move_line_idsDirtyFlag())
            domain.setActive_move_line_ids(model.getActive_move_line_ids());
        if(model.getDate_planned_finishedDirtyFlag())
            domain.setDate_planned_finished(model.getDate_planned_finished());
        if(model.getDate_finishedDirtyFlag())
            domain.setDate_finished(model.getDate_finished());
        if(model.getQty_remainingDirtyFlag())
            domain.setQty_remaining(model.getQty_remaining());
        if(model.getScrap_idsDirtyFlag())
            domain.setScrap_ids(model.getScrap_ids());
        if(model.getDuration_percentDirtyFlag())
            domain.setDuration_percent(model.getDuration_percent());
        if(model.getIdDirtyFlag())
            domain.setId(model.getId());
        if(model.getCreate_dateDirtyFlag())
            domain.setCreate_date(model.getCreate_date());
        if(model.getDuration_expectedDirtyFlag())
            domain.setDuration_expected(model.getDuration_expected());
        if(model.getMessage_has_error_counterDirtyFlag())
            domain.setMessage_has_error_counter(model.getMessage_has_error_counter());
        if(model.getMessage_unread_counterDirtyFlag())
            domain.setMessage_unread_counter(model.getMessage_unread_counter());
        if(model.getQty_producingDirtyFlag())
            domain.setQty_producing(model.getQty_producing());
        if(model.getProduction_dateDirtyFlag())
            domain.setProduction_date(model.getProduction_date());
        if(model.getWorksheetDirtyFlag())
            domain.setWorksheet(model.getWorksheet());
        if(model.getWorkcenter_id_textDirtyFlag())
            domain.setWorkcenter_id_text(model.getWorkcenter_id_text());
        if(model.getFinal_lot_id_textDirtyFlag())
            domain.setFinal_lot_id_text(model.getFinal_lot_id_text());
        if(model.getWorking_stateDirtyFlag())
            domain.setWorking_state(model.getWorking_state());
        if(model.getQty_productionDirtyFlag())
            domain.setQty_production(model.getQty_production());
        if(model.getProduct_uom_idDirtyFlag())
            domain.setProduct_uom_id(model.getProduct_uom_id());
        if(model.getCreate_uid_textDirtyFlag())
            domain.setCreate_uid_text(model.getCreate_uid_text());
        if(model.getProduction_availabilityDirtyFlag())
            domain.setProduction_availability(model.getProduction_availability());
        if(model.getProduction_stateDirtyFlag())
            domain.setProduction_state(model.getProduction_state());
        if(model.getNext_work_order_id_textDirtyFlag())
            domain.setNext_work_order_id_text(model.getNext_work_order_id_text());
        if(model.getOperation_id_textDirtyFlag())
            domain.setOperation_id_text(model.getOperation_id_text());
        if(model.getWrite_uid_textDirtyFlag())
            domain.setWrite_uid_text(model.getWrite_uid_text());
        if(model.getProduction_id_textDirtyFlag())
            domain.setProduction_id_text(model.getProduction_id_text());
        if(model.getProduct_id_textDirtyFlag())
            domain.setProduct_id_text(model.getProduct_id_text());
        if(model.getProduct_trackingDirtyFlag())
            domain.setProduct_tracking(model.getProduct_tracking());
        if(model.getFinal_lot_idDirtyFlag())
            domain.setFinal_lot_id(model.getFinal_lot_id());
        if(model.getWorkcenter_idDirtyFlag())
            domain.setWorkcenter_id(model.getWorkcenter_id());
        if(model.getProduction_idDirtyFlag())
            domain.setProduction_id(model.getProduction_id());
        if(model.getWrite_uidDirtyFlag())
            domain.setWrite_uid(model.getWrite_uid());
        if(model.getOperation_idDirtyFlag())
            domain.setOperation_id(model.getOperation_id());
        if(model.getNext_work_order_idDirtyFlag())
            domain.setNext_work_order_id(model.getNext_work_order_id());
        if(model.getProduct_idDirtyFlag())
            domain.setProduct_id(model.getProduct_id());
        if(model.getCreate_uidDirtyFlag())
            domain.setCreate_uid(model.getCreate_uid());
        return domain ;
    }


}
